<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>命令行中使用代理 | ACBS</title><meta name="keywords" content="windows"><meta name="author" content="boshen"><meta name="copyright" content="boshen"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="注意:测试代理可用不可用,不要用ping命令,而要使用curl命令,如 针对cmd  在VPN软件中设置一个端口,这里以ssr代理,1080端口为例   在cmd中执行 12set http_proxy&#x3D;http:&#x2F;&#x2F;127.0.0.1:1080set https_proxy&#x3D;https:&#x2F;&#x2F;127.0.0.1:1080      针对powershell  powershell走的是网络层, 正">
<meta property="og:type" content="article">
<meta property="og:title" content="命令行中使用代理">
<meta property="og:url" content="http://www.acbs.top/new/2021/02/07/%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%BB%A3%E7%90%86/index.html">
<meta property="og:site_name" content="ACBS">
<meta property="og:description" content="注意:测试代理可用不可用,不要用ping命令,而要使用curl命令,如 针对cmd  在VPN软件中设置一个端口,这里以ssr代理,1080端口为例   在cmd中执行 12set http_proxy&#x3D;http:&#x2F;&#x2F;127.0.0.1:1080set https_proxy&#x3D;https:&#x2F;&#x2F;127.0.0.1:1080      针对powershell  powershell走的是网络层, 正">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://www.acbs.top/new/img/orange.jpg">
<meta property="article:published_time" content="2021-02-07T01:15:12.000Z">
<meta property="article:modified_time" content="2021-02-13T00:33:11.596Z">
<meta property="article:author" content="boshen">
<meta property="article:tag" content="windows">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://www.acbs.top/new/img/orange.jpg"><link rel="shortcut icon" href="/new/img/favicon.png"><link rel="canonical" href="http://www.acbs.top/new/2021/02/07/%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%BB%A3%E7%90%86/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/new/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/new/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-02-13 08:33:11'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    })(window)</script><link rel="stylesheet" href="//at.alicdn.com/t/font_2373087_elarzsy8l6s.css"><meta name="generator" content="Hexo 5.3.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="/new/img/touxiang.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/new/archives/"><div class="headline">文章</div><div class="length-num">12</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/new/tags/"><div class="headline">标签</div><div class="length-num">7</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/new/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/new/archives/"><i class="fa-fw fa fa-clock"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/new/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/new/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/new/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></div><div class="menus_item"><a class="site-page" href="/new/photo/"><i class="fa-fw fas fa-images"></i><span> 图片</span></a></div><div class="menus_item"><a class="site-page" href="/new/start/"><i class="fa-fw fa fa-location-arrow"></i><span> 起始页</span></a></div><div class="menus_item"><a class="site-page" href="/new/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/new/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/new/">ACBS</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/new/archives/"><i class="fa-fw fa fa-clock"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/new/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/new/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/new/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></div><div class="menus_item"><a class="site-page" href="/new/photo/"><i class="fa-fw fas fa-images"></i><span> 图片</span></a></div><div class="menus_item"><a class="site-page" href="/new/start/"><i class="fa-fw fa fa-location-arrow"></i><span> 起始页</span></a></div><div class="menus_item"><a class="site-page" href="/new/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/new/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">命令行中使用代理</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-02-07T01:15:12.000Z" title="发表于 2021-02-07 09:15:12">2021-02-07</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-02-13T00:33:11.596Z" title="更新于 2021-02-13 08:33:11">2021-02-13</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div><article class="post-content" id="article-container"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h5 id="注意-测试代理可用不可用-不要用ping命令-而要使用curl命令-如"><a href="#注意-测试代理可用不可用-不要用ping命令-而要使用curl命令-如" class="headerlink" title="注意:测试代理可用不可用,不要用ping命令,而要使用curl命令,如"></a>注意:测试代理可用不可用,不要用ping命令,而要使用curl命令,如</h5><ul>
<li><h3 id="针对cmd"><a href="#针对cmd" class="headerlink" title="针对cmd"></a>针对cmd</h3></li>
</ul>
<p>在VPN软件中设置一个端口,这里以ssr代理,1080端口为例</p>
<img src="image-20201212210926621.png" alt="image-20201212210926621" style="zoom:67%;" />

<p>在cmd中执行</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">set</span> http_proxy=http://127.0.0.1:1080</span><br><span class="line"><span class="built_in">set</span> https_proxy=https://127.0.0.1:1080</span><br></pre></td></tr></table></figure>




<ul>
<li><h3 id="针对powershell"><a href="#针对powershell" class="headerlink" title="针对powershell"></a>针对powershell</h3></li>
</ul>
<p>powershell走的是网络层, 正好能被SSR、SS或V2Ray代理，不用手动设置了, 而无需手动设置代理</p>
<p>但是要是想代理,也不是不行</p>
<figure class="highlight powershell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$env:http_proxy</span>=<span class="string">&quot;http://127.0.0.1:1080&quot;</span></span><br><span class="line"><span class="variable">$env:https_proxy</span>=<span class="string">&quot;http://127.0.0.1:1080&quot;</span></span><br></pre></td></tr></table></figure>
<ul>
<li><h3 id="git-bash"><a href="#git-bash" class="headerlink" title="git bash"></a>git bash</h3></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git config --global https.proxy http://127.0.0.1:1080</span><br><span class="line">git config --global https.proxy https://127.0.0.1:1080</span><br><span class="line">git config --global http.proxy <span class="string">&#x27;socks5://127.0.0.1:1080&#x27;</span> </span><br><span class="line">git config --global https.proxy <span class="string">&#x27;socks5://127.0.0.1:1080&#x27;</span></span><br></pre></td></tr></table></figure>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">boshen</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://www.acbs.top/new/2021/02/07/%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%BB%A3%E7%90%86/">http://www.acbs.top/new/2021/02/07/%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E4%BD%BF%E7%94%A8%E4%BB%A3%E7%90%86/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://www.acbs.top/new" target="_blank">ACBS</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/new/tags/windows/">windows</a></div><div class="post_share"><div class="social-share" data-image="/new/img/orange.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/new/2021/02/10/Right-Menu-To-Copy-Path/"><img class="prev-cover" src="/new/img/orange.jpg" onerror="onerror=null;src='/new/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">在右键菜单中添加复制文件名或者路径的功能(使用说明)</div></div></a></div><div class="next-post pull-right"><a href="/new/2021/02/06/%E9%80%9A%E8%BF%87socket%E8%BF%9B%E8%A1%8C%E6%9C%AC%E5%9C%B0%E7%9A%84%E8%BF%9B%E7%A8%8B%E9%97%B4%E9%80%9A%E4%BF%A1/"><img class="next-cover" src="/new/img/orange.jpg" onerror="onerror=null;src='/new/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">通过socket进行本地的进程间通信</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/new/2021/02/04/路径过长/" title="Windows10路径过长 解决办法"><img class="cover" src="/new/img/orange.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-04</div><div class="title">Windows10路径过长 解决办法</div></div></a></div><div><a href="/new/2021/02/04/Python国内镜像/" title="Python 国内镜像"><img class="cover" src="/new/img/orange.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-04</div><div class="title">Python 国内镜像</div></div></a></div><div><a href="/new/2021/02/10/CMD检查本地端口被占用情况/" title="CMD检查本地端口被占用情况"><img class="cover" src="/new/img/orange.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-10</div><div class="title">CMD检查本地端口被占用情况</div></div></a></div><div><a href="/new/2021/02/10/Right-Menu-To-Copy-Path-principle/" title="在右键菜单中添加复制文件名或者路径的功能(原理)"><img class="cover" src="/new/img/orange.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-10</div><div class="title">在右键菜单中添加复制文件名或者路径的功能(原理)</div></div></a></div><div><a href="/new/2021/02/10/Right-Menu-To-Copy-Path/" title="在右键菜单中添加复制文件名或者路径的功能(使用说明)"><img class="cover" src="/new/img/orange.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-10</div><div class="title">在右键菜单中添加复制文件名或者路径的功能(使用说明)</div></div></a></div><div><a href="/new/2021/02/10/完整的reg操作注册表/" title="完整的reg操作注册表"><img class="cover" src="/new/img/orange.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-10</div><div class="title">完整的reg操作注册表</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="/new/img/touxiang.png" onerror="this.onerror=null;this.src='/new/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">boshen</div><div class="author-info__description"></div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/new/archives/"><div class="headline">文章</div><div class="length-num">12</div></a></div><div class="card-info-data-item is-center"><a href="/new/tags/"><div class="headline">标签</div><div class="length-num">7</div></a></div><div class="card-info-data-item is-center"><a href="/new/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/zephms"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/zephms" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:ab@dfgh.asia" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="/new/info/qq" target="_blank" title="QQ"><i class="iconfont icon-QQ1"></i></a></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%B3%A8%E6%84%8F-%E6%B5%8B%E8%AF%95%E4%BB%A3%E7%90%86%E5%8F%AF%E7%94%A8%E4%B8%8D%E5%8F%AF%E7%94%A8-%E4%B8%8D%E8%A6%81%E7%94%A8ping%E5%91%BD%E4%BB%A4-%E8%80%8C%E8%A6%81%E4%BD%BF%E7%94%A8curl%E5%91%BD%E4%BB%A4-%E5%A6%82"><span class="toc-number">1.</span> <span class="toc-text">注意:测试代理可用不可用,不要用ping命令,而要使用curl命令,如</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%92%88%E5%AF%B9cmd"><span class="toc-number"></span> <span class="toc-text">针对cmd</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%92%88%E5%AF%B9powershell"><span class="toc-number"></span> <span class="toc-text">针对powershell</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#git-bash"><span class="toc-number"></span> <span class="toc-text">git bash</span></a></div></div></div></div></main><footer id="footer"></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/new/js/utils.js"></script><script src="/new/js/main.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>